<?php

/*

Unequip Items (unequip.pro.php)

*/
ob_start();
$rank_check = 1;
include "header.inc.php";

$findItem = fetch("SELECT * FROM equipped_items2 WHERE id = '$itemid' AND game = '$game'");
$findOwner = fetch("SELECT * FROM user_pets2 WHERE id = '$findItem[pet_id]' AND game = '$game'");
if ($findOwner[owner] != "$userid")
{
	die(header(error("battle_items.php?game=$game","That ain't your item.")));
}

$parts2_left = "$findItem[parts]";

if (($parts2_left == "b") OR ($parts2_left == "i"))
{
	$parts2_left = 1;
}

if ($parts2_left <= "0") { $parts2_left = 1; }

mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','$findItem[item_id]','$parts2_left','$game')");
mysql_query("DELETE FROM equipped_items2 WHERE id = '$itemid' AND game = '$game'");

header(error("battle_items.php?game=$game","Your item has been returned to your inventory."));

?>